home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: October 25, 1996
- // Author: mm
- //
- // Description:
- // This a helper script which will create a new bookmark
- // containing the objects displayed within an editor.
- //
- // Input Arguments:
- // The name of the editor to modify
- // The type of the bookmark to create
- //
- // Whether a dialog should be popped to prompt the
- // user for a bookmark name or not.
- //
- // Return Value:
- // None.
- //
-
- global proc
- createBookmark (string $editor, string $type, int $popDialog)
- {
- // The default base name for bookmarks
- //
- string $defaultBaseName = "Bookmark";
-
- // Make sure the editor exists
- //
- if (!`editor -exists $editor`) {
- error "Editor not found";
- }
-
- // First, find out what is connected to this editor
- //
- string $mainListConnection = `editor -query -mainListConnection $editor`;
- if ($mainListConnection == "") {
- if (`modelEditor -exists $editor`) {
- $mainListConnection = "activeList";
- }
- else {
- error "No objects to bookmark";
- }
- }
-
- // Now create a new bookmark, and add all of the objects to it
- //
- string $objects[];
- // If this is a model editor and it has an objectSet then bookmark those members
- //
- int $foundObjects = false;
- if (`modelEditor -exists $editor`) {
- string $objectSet = `modelEditor -query -viewObjects $editor`;
- if ($objectSet != "") {
- $objects = `sets -query $objectSet`;
- $foundObjects = true;
- }
- }
- if (!$foundObjects) {
- $objects = `selectionConnection -query -object $mainListConnection`;
- }
- if (size ($objects) > 0) {
- // Create a bookmark set and get its suggested name
- //
- string $bookmark = `sets -text $type -name $defaultBaseName`;
- if( $popDialog ) {
- // Let the user name the bookmark
- //
- string $response = `promptDialog
- -title "Create Bookmark"
- -message "Bookmark Name:"
- -text $bookmark
- -button "OK"
- -button "Cancel"
- -defaultButton "OK"
- -cancelButton "Cancel"
- -dismissString "Cancel"`;
- if ($response == "OK") {
- //
- // If the user is happy, then add the bookmark
- //
- sets -addElement $bookmark $objects;
- string $name = `promptDialog -query -text`;
- rename $bookmark $name;
- }
- else {
- // Otherwise delete the bookmark set
- //
- delete $bookmark;
- }
- }
- }
- else {
- warning "No objects to bookmark";
- }
- }
-